package com.cinyi.cyds.base.listener;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;

import com.cinyi.ormlite.ConfigurationException;
import com.cinyi.ormlite.web.OrmliteContextListener;
import com.cinyi.ormlite.web.dcp.DbConnectionManager;

public class SpringContextListener extends OrmliteContextListener{
	private final static Logger logg = Logger.getLogger(SpringContextListener.class);

	@Override
	public void buildOrmliteWebContext(ApplicationContext ctx) {
		super.buildOrmliteWebContext(ctx);
		
		try {
			getOrmliteWebContext().addBundle("config");
			getOrmliteWebContext().addBundle("message");
		} catch (ConfigurationException e) {
			e.printStackTrace();
		}
		
		logg.info("cfg session  info:"+getOrmliteWebContext().getConfiguration().get("session_info"));
	
		DbConnectionManager.getInstance().start(getOrmliteWebContext().getConfiguration());
		
	}
	
}


